feat(init): auto-install CC and Codex OTEL configs during init#248
feat(init): auto-install CC and Codex OTEL configs during init#248
Conversation
Make `shelltime init` a true one-stop setup by automatically installing Claude Code and Codex OTEL configurations after daemon install. Failures are non-blocking to avoid halting the init process. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
| if err := commandCodexInstall(c); err != nil { | ||
| color.Red.Printf("Failed to install Codex OTEL config: %v\n", err) | ||
| } |
There was a problem hiding this comment.
🟡 Duplicate error message printed when Codex OTEL install fails during init
When commandCodexInstall fails during shelltime init, the user sees the same error message printed twice.
Root Cause
commandCodexInstall at commands/codex.go:37-39 already prints the error and then returns it:
if err := service.Install(); err != nil {
color.Red.Printf("Failed to install Codex OTEL config: %v\n", err)
return err
}Then commandInit at commands/init.go:46-48 catches the returned error and prints it again:
if err := commandCodexInstall(c); err != nil {
color.Red.Printf("Failed to install Codex OTEL config: %v\n", err)
}This is inconsistent with how commandCCInstall works — that function handles errors internally for each shell and always returns nil (commands/cc.go:57), so the error handler in init.go:41-43 never triggers.
Impact: When Codex OTEL config installation fails during shelltime init, the user sees two nearly identical red error lines, which is confusing.
Prompt for agents
There are two reasonable approaches to fix the duplicate error message:
Option A (preferred): Make commandCodexInstall consistent with commandCCInstall by not returning the error after printing it. In commands/codex.go, lines 37-39, remove the `return err` so the function always returns nil (matching the pattern used in commandCCInstall). This way init.go's error handler won't trigger.
Option B: In commands/init.go lines 46-48, don't print the error since commandCodexInstall already prints it. Change to just: `_ = commandCodexInstall(c)` or `commandCodexInstall(c) //nolint:errcheck`. But this loses the ability to detect failure from the caller side.
Option A is cleaner as it makes both CC and Codex install functions behave the same way.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Code Review
This pull request extends the init command to automatically install configurations for Claude Code and Codex. The implementation reuses existing installation commands. My review identifies an issue with inconsistent error handling in the init command when calling these sub-commands, which leads to dead code and duplicate error logging. I've provided a suggestion to make the code clearer and fix these issues within the scope of the changed file.
| // Step 4: Install Claude Code OTEL configuration | ||
| if err := commandCCInstall(c); err != nil { | ||
| color.Red.Printf("Failed to install Claude Code OTEL config: %v\n", err) | ||
| } | ||
|
|
||
| // Step 5: Install Codex OTEL configuration | ||
| if err := commandCodexInstall(c); err != nil { | ||
| color.Red.Printf("Failed to install Codex OTEL config: %v\n", err) | ||
| } |
There was a problem hiding this comment.
The error handling for the new installation steps is inconsistent. commandCCInstall always returns nil (making the error check on line 41 dead code), while commandCodexInstall logs an error and also returns it (leading to duplicate logging on line 47).
A better long-term solution would be to refactor commandCCInstall to return errors and commandCodexInstall to not log them, letting commandInit handle all logging centrally.
For an immediate improvement within this file, you can adjust the calls to reflect the current behavior of the sub-commands. This avoids the dead code and duplicate logging issues.
// Step 4: Install Claude Code OTEL configuration
// commandCCInstall handles its own logging and does not return errors.
commandCCInstall(c)
// Step 5: Install Codex OTEL configuration
// commandCodexInstall handles its own error logging, so we ignore the returned error here to avoid duplicate logs.
_ = commandCodexInstall(c)
Summary
shelltime inita one-stop setup by auto-installing Claude Code and Codex OTEL configurations after the daemon install stepcommandCCInstallandcommandCodexInstallwhich are already idempotentTest plan
go buildcompiles successfullygo vet ./commands/...passesgo test ./commands/... ./model/...passesshelltime initend-to-end and verify CC/Codex OTEL configs are installed🤖 Generated with Claude Code